/**
 * Copyright 2007-2008. Chongqing First Information & Network Co., Ltd. All rights reserved.
 * <a>http://www.cqfirst.com.cn</a>
 */
package com.cq.bd.base;

import java.io.Serializable;

import com.cq.bd.BDException;
import com.cq.bd.security.UserDetails;
import com.cq.bd.utils.AuthenticationHelper;

/**
 * DWR基类，提供与session访问
 * 
 * @author huangmy
 * @date   2009-10-3
 */
public class BaseDwr implements Serializable {
	private static final long serialVersionUID = 2732807754949427189L;

	/**
	 * 获取session用户
	 * 
	 * @return 用户实例
	 */
	public UserDetails getCurrentUser() {
		Object ud = AuthenticationHelper.getUser();
		if (ud == null) {
			throw new BDException("登录超时或未登录系统,请重新登录");
		} else {
			return (UserDetails)ud;
		}
	}

	/**
	 * 获取登录ip
	 * 
	 * @return
	 */
	public String getIpAddress() {
		return AuthenticationHelper.getIpAddress();
	}
}
